package net.kodra.supereasy.jpa.server.model;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

import com.google.appengine.api.datastore.Key;

@Entity
@Table(name="ad_change_logs")
public class AdChangeLog implements Serializable
{

  private static final long serialVersionUID = 1;

  public enum TypeEnum {OTHER, CREATE, MODIFY, DELETE, ACTIVATE, DEACTIVATE}

  @Id
  @GeneratedValue(strategy = GenerationType.IDENTITY)
  private Key key;

  private Integer realEstateId;

  private TypeEnum changeType;

  private Date timestamp;

  private String optional;


  public AdChangeLog()
  {
  }

  public AdChangeLog(TypeEnum changeType, Date timestamp)
  {
    this.setChangeType(changeType);
    this.setTimestamp(timestamp);
  }

  public AdChangeLog(TypeEnum changeType, String optional)
  {
    this(changeType, new Date());
    this.setOptional(optional);
  }


  public int getRealEstateId()
  {
    return realEstateId;
  }

  public void setRealEstateId(int realEstateId)
  {
    this.realEstateId = realEstateId;
  }

  public TypeEnum getChangeType()
  {
    return changeType;
  }

  public void setChangeType(TypeEnum changeType)
  {
    this.changeType = changeType;
  }

  public Date getTimestamp()
  {
    return timestamp;
  }

  public void setTimestamp(Date timestamp)
  {
    this.timestamp = timestamp;
  }

  public String getOptional()
  {
    return optional;
  }

  public void setOptional(String optional)
  {
    this.optional = optional;
  }


  public String toString()
  {
    return "AdChangeLog={realEstateId=" + realEstateId + "; changeType=" + changeType + "; optional=" + optional + "}";
  }

}
